import request from '@/utils/request'

export interface WarehouseDTO {
  warehouseId?: string
  warehouseCode: string
  warehouseName: string
  orgId?: string
  enableBin?: number
  enableBatch?: number
  enableSerial?: number
  status?: number
  remark?: string
}

export function pageWarehouse(params: { pageNum: number; pageSize: number; warehouseCode?: string; warehouseName?: string; status?: number; enableBin?: number; enableBatch?: number; enableSerial?: number; startTime?: string; endTime?: string }) {
  return request({ url: '/erp/warehouse/page', method: 'get', params })
}

export function getWarehouse(id: string) {
  return request({ url: `/erp/warehouse/${id}`, method: 'get' })
}

export function createWarehouse(data: WarehouseDTO) {
  return request({ url: '/erp/warehouse', method: 'post', data })
}

export function updateWarehouse(id: string, data: WarehouseDTO) {
  return request({ url: `/erp/warehouse/${String(id)}`, method: 'put', data })
}

export function deleteWarehouse(id: string) {
  return request({ url: `/erp/warehouse/${String(id)}`, method: 'delete' })
}

export function deleteWarehouseBatch(ids: string[]) {
  return request({ url: '/erp/warehouse/batch-delete', method: 'post', data: ids })
}

export function exportWarehouse(params: { warehouseCode?: string; warehouseName?: string; status?: number; enableBin?: number; enableBatch?: number; enableSerial?: number; startTime?: string; endTime?: string; ids?: string[] }) {
  return request({ url: '/erp/warehouse/export', method: 'get', params, responseType: 'blob' })
}

export function getWarehouseIds(params: { warehouseCode?: string; warehouseName?: string; status?: number; enableBin?: number; enableBatch?: number; enableSerial?: number; startTime?: string; endTime?: string }) {
  return request({ url: '/erp/warehouse/ids', method: 'get', params })
}

export function listWarehouse(params: { pageNum: number; pageSize: number }) {
  return request({ url: '/erp/warehouse/page', method: 'get', params })
}


